package com.example.yiwei.crm.view.activity.customerActivity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import com.bigkoo.pickerview.TimePickerView;
import com.example.yiwei.crm.R;
import com.example.yiwei.crm.base.BaseActivity;
import com.example.yiwei.crm.base.baseClass;
import com.example.yiwei.crm.dao.managerDao;
import com.example.yiwei.crm.dao_impl.managerDaoImpl;
import com.example.yiwei.crm.data.GetAppointment;
import com.example.yiwei.crm.entity.ApointmentEntity;
import com.example.yiwei.crm.entity.BZFLEntity;
import com.example.yiwei.crm.entity.HospitalEntity;
import com.example.yiwei.crm.entity.KSEntity;
import com.example.yiwei.crm.entity.managerEntity;
import com.example.yiwei.crm.json.YYSpinnerJson;
import com.example.yiwei.crm.util.NetWorkUtils;
import com.example.yiwei.crm.util.SC;
import com.example.yiwei.crm.view.activity.coordinationActivity.SimpleintmentActivity;

import org.json.JSONException;
import org.json.JSONObject;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class CustomerAppointmentAcitity extends BaseActivity {
    private Spinner spinner_hospital,spinner_department,spinner_doctor,spinner_qdfl,spinner_qdly,
            spinner_disease_category,spinner_disease,spinner_jd;
    private EditText edit_additional;
    private TextView txt_appointmen_date;
    private Button btn_show;
    ImageView btn_back,btn_commit;
    private TimePickerView mpv;
    String appointment_date;
    List<String> hospital_list,manager_list,department_list,disease_category_list,disease_list,qdfl_list,qdly_list,jd_list;
    String result;
    String hospital_name,hospital_bianma,department_name,department_bianma,disease_category,disease,disease_bianma,qdfl,qdly;
    int hospital_id,department_id,disease_category_id,disease_id,qdfl_id,qdly_id;
    private ArrayAdapter adapter ,adapter2,adapter3,adapter4,adapter5,adapter6,adapter7,adapter8;
    private SharedPreferences sp;
    private List<HospitalEntity> list1;
    private List<KSEntity> list2;
    private List<BZFLEntity> list4;
    private List<BZFLEntity> list3;
    private List<BZFLEntity> list5;
    private List<BZFLEntity> list6;
    private List<managerEntity> list7;
    private managerEntity managerEntityfz;
    private managerEntity managerEntityjd;
    private ApointmentEntity apo;
    int manager_id,jd_id;
    String jd_name,manager_name,department_manager_name,deoartment_jd_name;
    Date date1,date2;
    private int A = 1,B = 1,i3 = 1,i4 = 1,i5 = 1,i6 = 1,i7 = 1,i8 = 1;
    private TextView txt_title;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_customer_appointment_acitity);
        sp = getSharedPreferences("login", Context.MODE_PRIVATE);
        spinner_hospital= (Spinner) findViewById(R.id.customerApointmentMessage_spinner_hospital);
        spinner_department= (Spinner) findViewById(R.id.customerApointmentMessage_spinner_department);
        spinner_doctor= (Spinner) findViewById(R.id.customerApointmentMessage_spinner_doctor);
        spinner_qdfl= (Spinner) findViewById(R.id.customerApointmentMessage_channel_classification);
        spinner_jd = (Spinner) findViewById(R.id.customerApointmentMessage_jd_ren);
        spinner_qdly= (Spinner) findViewById(R.id.customerApointmentMessage_channel_source);
        spinner_disease_category= (Spinner) findViewById(R.id.customerApointmentMessage_spinner_disease_category);
        spinner_disease= (Spinner) findViewById(R.id.customerApointmentMessage_spinner_disease);
        edit_additional= (EditText) findViewById(R.id.customerApointmentMessage_edit_additional_remarks);
        txt_appointmen_date= (TextView) findViewById(R.id.customerApointmentMessage_tv_time);
        txt_title= (TextView) findViewById(R.id.customer_appointment_title);
        if ("updata".equals(getIntent().getStringExtra("TAG"))){
            txt_title.setText("修改预约信息");
        }else{
            txt_title.setText("新增预约信息");
        }
        btn_show= (Button) findViewById(R.id.customerApointmentMessage_btn_time);
        btn_back= (ImageView) findViewById(R.id.
                customerApointmentMessage_btn_back);
        btn_commit= (ImageView) findViewById(R.id.customerApointmentMessage_btn_commit);
        //创建选择器
        mpv = new TimePickerView(this, TimePickerView.Type.YEAR_MONTH_DAY);
        //设置时间范围
        Calendar calendar = Calendar.getInstance();
        if ("updata".equals(getIntent().getStringExtra("TAG"))){
            apo = GetAppointment.apoint;
        }
        mpv.setRange(calendar.get(Calendar.YEAR) - 100, calendar.get(Calendar.YEAR) + 100);
        //插入时间
        mpv.setTime(new Date());
        //选择监听
        mpv.setOnTimeSelectListener(new TimePickerView.OnTimeSelectListener() {

            @Override
            public void onTimeSelect(Date date) {
                appointment_date=getTime(date);
                txt_appointmen_date.setText(appointment_date);
            }
        });
        btn_show.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mpv.show();
            }
        });
        new Thread(new Runnable() {
            @Override
            public void run() {
                SC sc = new SC();
                JSONObject object = sc.storage(sp);
                Log.d("cc",object.toString());
                String json = object.toString();

                String result = NetWorkUtils.getCount(baseClass.find_hospital_add_yy_URL, json);
                list1= YYSpinnerJson.getHospital(result);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        hospital_list= new ArrayList<>();
                        for (int i2=0;i2<list1.size();i2++){
                            hospital_list.add( list1.get(i2).getName());
                        }
                        adapter = new ArrayAdapter(CustomerAppointmentAcitity.this,R.layout.spinner_display_style,R.id.txtvwSpinner, hospital_list);
                        adapter.setDropDownViewResource(R.layout.spinner_dropdown_style);
                        spinner_hospital.setAdapter(adapter);
                        spinner_hospital.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                            @Override
                            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                                    hospital_name=list1.get(position).getName();
                                    hospital_bianma = list1.get(position).getBianma();
                                    B++;
                                if ("updata".equals(getIntent().getStringExtra("TAG"))&&A==1){
                                    for (int i = 0;i<hospital_list.size();i++){
                                        if (hospital_list.get(i).equals(apo.getAppoint_hospital())){
                                            spinner_hospital.setSelection(i);
                                            A++;
                                        }
                                    }
                                }
                                new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        SC sc = new SC();
                                        JSONObject object1 = sc.storage(sp);
                                        try {

                                                object1.put("UAA02",hospital_bianma);

                                        } catch (JSONException e) {
                                            e.printStackTrace();
                                        }
                                        String json = object1.toString();
                                        String result = NetWorkUtils.getCount(baseClass.find_KS_URL, json);
                                        list2 = YYSpinnerJson.getKS(result);
                                        runOnUiThread(new Runnable() {
                                            @Override
                                            public void run() {
                                                department_list = new ArrayList<String>();
                                                for (int i2=0;i2<list2.size();i2++){
                                                    department_list.add( list2.get(i2).getName());
                                                }
                                                adapter2 = new ArrayAdapter(CustomerAppointmentAcitity.this,R.layout.spinner_display_style,R.id.txtvwSpinner,department_list);
                                                adapter2.setDropDownViewResource(R.layout.spinner_dropdown_style);
                                                spinner_department.setAdapter(adapter2);
                                                spinner_department.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                                                    @Override
                                                    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                                                            department_name=list2.get(position).getName();
                                                            department_bianma = list2.get(position).getBianma();
                                                        if ("updata".equals(getIntent().getStringExtra("TAG"))&&B==2){
                                                            System.out.print(department_list.toString()+"2252552555");
                                                            for (int i = 0;i<department_list.size();i++){
                                                                if (department_list.get(i).equals(apo.getAppint_department())){
                                                                    spinner_department.setSelection(i);
                                                                    System.out.print("545465655");

                                                                }
                                                            }
                                                        }
                                                    }
                                                    @Override
                                                    public void onNothingSelected(AdapterView<?> parent) {

                                                    }
                                                });

                                            }
                                        });
                                    }
                                }).start();
                            }
                            @Override
                            public void onNothingSelected(AdapterView<?> parent) {

                            }
                        });
                    }
                });
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                SC sc1 = new SC();
                JSONObject object3 = sc1.storage(sp);
                String json2 = object3.toString();
                String result2 = NetWorkUtils.getCount(baseClass.find_BZFL_URL,json2);
                list3 = YYSpinnerJson.getBZFL(result2);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        disease_category_list= new ArrayList<>();
                        disease_category_list.add("");
                        for (int i2=0;i2<list3.size();i2++){
                            disease_category_list.add( list3.get(i2).getName());
                        }
                        adapter3 = new ArrayAdapter(CustomerAppointmentAcitity.this,R.layout.spinner_display_style,R.id.txtvwSpinner,disease_category_list);
                        adapter3.setDropDownViewResource(R.layout.spinner_dropdown_style);
                        spinner_disease_category.setAdapter(adapter3);
                        spinner_disease_category.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                            @Override
                            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                                if (position>0){
                                    disease_category=list3.get(position-1).getName();
                                    disease_category_id = list3.get(position-1).getId();
                                    i4++;
                                }
                                if ("updata".equals(getIntent().getStringExtra("TAG"))&&i3==1){
                                    for (int i = 0;i<disease_category_list.size();i++){
                                        if (disease_category_list.get(i).equals(apo.getDisease_category())){
                                            spinner_disease_category.setSelection(i);
                                            i3++;
                                        }
                                    }
                                }
                                new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        SC sc = new SC();
                                        JSONObject object2 = sc.storage(sp);
                                        try {

                                                object2.put("AKB01",disease_category_id);


                                        } catch (JSONException e) {
                                            e.printStackTrace();
                                        }
                                        Log.d("a",object2.toString());
                                        String json = object2.toString();
                                        Log.d("a",json);
                                        String result = NetWorkUtils.getCount(baseClass.find_BZ_URL, json);
                                        list4 = YYSpinnerJson.getBZ(result);
                                        runOnUiThread(new Runnable() {
                                            @Override
                                            public void run() {
                                                disease_list = new ArrayList<String>();
                                                disease_list.add(0,"");
                                                for (int i2=0;i2<list4.size();i2++){
                                                    disease_list.add( list4.get(i2).getName());
                                                }
                                                adapter4 = new ArrayAdapter(CustomerAppointmentAcitity.this,R.layout.spinner_display_style,R.id.txtvwSpinner,disease_list);
                                                adapter4.setDropDownViewResource(R.layout.spinner_dropdown_style);
                                                spinner_disease.setAdapter(adapter4);
                                                spinner_disease.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                                                    @Override
                                                    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                                                        if (position>0){
                                                            disease=list4.get(position-1).getName();
                                                            disease_id = list4.get(position-1).getId();
                                                        }
                                                        if ("updata".equals(getIntent().getStringExtra("TAG"))&&i4==2){
                                                            for (int i = 0;i<disease_list.size();i++){
                                                                if (disease_list.get(i).equals(apo.getDisease())){
                                                                    spinner_disease.setSelection(i);

                                                                }
                                                            }
                                                        }
                                                    }
                                                    @Override
                                                    public void onNothingSelected(AdapterView<?> parent) {

                                                    }
                                                });
                                            }
                                        });
                                    }
                                }).start();
                            }
                            @Override
                            public void onNothingSelected(AdapterView<?> parent) {

                            }
                        });
                    }
                });
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                SC sc1 = new SC();
                JSONObject object3 = sc1.storage(sp);
                String json2 = object3.toString();
                String result2 = NetWorkUtils.getCount(baseClass.find_QDFL_URL,json2);
                list5 = YYSpinnerJson.getQDFL(result2);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        qdfl_list= new ArrayList<>();
                        qdfl_list.add("");
                        for (int i2=0;i2<list5.size();i2++){
                            qdfl_list.add(list5.get(i2).getName());
                        }
                        adapter5 = new ArrayAdapter(CustomerAppointmentAcitity.this,R.layout.spinner_display_style,R.id.txtvwSpinner,qdfl_list);
                        adapter5.setDropDownViewResource(R.layout.spinner_dropdown_style);
                        spinner_qdfl.setAdapter(adapter5);
                        spinner_qdfl.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                            @Override
                            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                                if (position>0){
                                    qdfl=list5.get(position-1).getName();
                                    qdfl_id = list5.get(position-1).getId();
                                    i6++;
                                }
                                if ("updata".equals(getIntent().getStringExtra("TAG"))&&i5==1){
                                    for (int i = 0;i<qdfl_list.size();i++){
                                        if (qdfl_list.get(i).equals(apo.getClue_channel_classification())){
                                            spinner_qdfl.setSelection(i);
                                            i5++;
                                        }
                                    }
                                }
                                new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        SC sc = new SC();
                                        JSONObject object2 = sc.storage(sp);
                                        try {
                                                object2.put("AKC01",qdfl_id);
                                        } catch (JSONException e) {
                                            e.printStackTrace();
                                        }
                                        Log.d("a",object2.toString());
                                        String json = object2.toString();
                                        Log.d("a",json);
                                        String result = NetWorkUtils.getCount(baseClass.find_QD_URL, json);
                                        list6 = YYSpinnerJson.getQDLY(result);

                                        runOnUiThread(new Runnable() {
                                            @Override
                                            public void run() {
                                                qdly_list = new ArrayList<String>();
                                                qdly_list.add("");
                                                for (int i2=0;i2<list6.size();i2++){
                                                    qdly_list.add( list6.get(i2).getName());
                                                }
                                                adapter6 = new ArrayAdapter(CustomerAppointmentAcitity.this,R.layout.spinner_display_style,R.id.txtvwSpinner,qdly_list);
                                                adapter6.setDropDownViewResource(R.layout.spinner_dropdown_style);
                                                spinner_qdly.setAdapter(adapter6);
                                                spinner_qdly.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                                                    @Override
                                                    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                                                        if (position>0){
                                                            qdly=list6.get(position-1).getName();
                                                            qdly_id = list6.get(position-1).getId();
                                                        }
                                                        if ("updata".equals(getIntent().getStringExtra("TAG"))&&i6==2){
                                                            for (int i = 0;i<qdly_list.size();i++){
                                                                if (qdly_list.get(i).equals(apo.getClue_channel_source())){
                                                                    spinner_qdly.setSelection(i);

                                                                }
                                                            }
                                                        }
                                                    }
                                                    @Override
                                                    public void onNothingSelected(AdapterView<?> parent) {

                                                    }
                                                });
                                            }
                                        });
                                    }
                                }).start();
                            }
                            @Override
                            public void onNothingSelected(AdapterView<?> parent) {

                            }
                        });
                    }                });
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                SC sc = new SC();
                JSONObject object = sc.storage(sp);
                try {
                    object.put("admin",sp.getString("admin",null));
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                String json = object.toString();
                managerDao manaDao=new managerDaoImpl();
                list7=manaDao.queryAllManager(baseClass.query_manager_url,json);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        manager_list=new ArrayList<String>();
                        jd_list = new ArrayList<String>();
                        for (int i=0;i<list7.size();i++){
                            jd_list.add(list7.get(i).getManager_name());
                            manager_list.add(list7.get(i).getManager_name());
                        }

                        adapter7 = new ArrayAdapter(CustomerAppointmentAcitity.this,R.layout.spinner_display_style,R.id.txtvwSpinner,manager_list);
                        adapter7.setDropDownViewResource(R.layout.spinner_dropdown_style);
                        spinner_doctor.setAdapter(adapter7);
                        spinner_doctor.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                            @Override
                            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                                if (position==0||position>0){
                                    manager_id= list7.get(position).getManager_id();
                                    manager_name=list7.get(position).getManager_name();
                                    department_manager_name=list7.get(position).getDepartment();
                                }
                                if ("updata".equals(getIntent().getStringExtra("TAG"))&&i7==1){
                                    for (int i = 0;i<manager_list.size();i++){
                                        if (manager_list.get(i).equals(apo.getCurrent_create_name())){
                                            spinner_doctor.setSelection(i);
                                            i7++;
                                        }
                                    }
                                }
                            }

                            @Override
                            public void onNothingSelected(AdapterView<?> parent) {

                            }
                        });
                        adapter8 = new ArrayAdapter(CustomerAppointmentAcitity.this,R.layout.spinner_display_style,R.id.txtvwSpinner,jd_list);
                        adapter8.setDropDownViewResource(R.layout.spinner_dropdown_style);
                        jd_list.add(0,"");
                        spinner_jd.setAdapter(adapter8);
                        spinner_jd.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                            @Override
                            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                                if (position>0){
                                    jd_id = list7.get(position-1).getManager_id();
                                    jd_name=list7.get(position-1).getManager_name();
                                    deoartment_jd_name=list7.get(position-1).getDepartment();
                                }
                                if ("updata".equals(getIntent().getStringExtra("TAG"))&&i8==1){
                                    for (int i = 0;i<jd_list.size();i++){
                                        if (jd_list.get(i).equals(apo.getJd_name())){
                                            spinner_jd.setSelection(i);
                                            i8++;
                                        }
                                    }
                                }
                            }

                            @Override
                            public void onNothingSelected(AdapterView<?> parent) {

                            }
                        });
                    }
                });
            }
        }).start();
        btn_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        btn_commit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                add();
            }
        });
        if ("updata".equals(getIntent().getStringExtra("TAG"))){
            if (apo.getAppoint_date()!=null){
                SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");//小写的mm表示的是分钟
                String dstr=apo.getAppoint_date();
                Date date= null;
                try {
                    date = sdf.parse(dstr);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                String s = getTime(date);
                txt_appointmen_date.setText(s);
            }


            edit_additional.setText(apo.getAppoint_additional());
        }
    }

    public void add(){
        String a = getTime(new Date());
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

        SimpleDateFormat sdf1=new SimpleDateFormat("yyyy-MM-dd");//小写的mm表示的是分钟
        String dstr=txt_appointmen_date.getText().toString();
        try {
            date1=sdf1.parse(dstr);
            date2 =  formatter.parse(a);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        if (date1!=null&&date2!=null){
            if (!date1.before(date2)){
                btn_commit.setVisibility(View.GONE);
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        SC sc = new SC();
                        JSONObject json=sc.storage(sp);
                        try {
                            if ("updata".equals(getIntent().getStringExtra("TAG"))){
                                json.put("KAA01", apo.getCustomer_id());
                            }else{
                                json.put("KAA01", getIntent().getIntExtra("ID",0));
                            }
                            json.put("UAA02",hospital_bianma);
                            json.put("KYA02",txt_appointmen_date.getText().toString());
                            json.put("ADD02",department_bianma);
                            json.put("CID03",sp.getString("CID03",null));
                            json.put("AKB01",disease_category_id);
                            json.put("AKM01",disease_id);
                                json.put("KYA19",manager_id);
                                json.put("KYA20",manager_name);
                                json.put("KYA23",department_manager_name);
                                json.put("KYA78",jd_id);
                                json.put("KYA78A",jd_name);
                                json.put("KYA80",deoartment_jd_name);
                            json.put("AKC01",qdfl_id);
                            if ("updata".equals(getIntent().getStringExtra("TAG"))){
                                json.put("KYA01",apo.getAppoint_id());
                            }
                            json.put("AKD01",qdly_id);
                            json.put("KYA03",edit_additional.getText().toString());
                            String content=json.toString();
                            if ("updata".equals(getIntent().getStringExtra("TAG"))){
                                result = NetWorkUtils.getCount(baseClass.EDIT_YUYUE_URL,content);
                            }else{
                                result=NetWorkUtils.getCount(baseClass.SAVE_YUYUE_URL,content);
                            }

                            Log.d("aa",result);
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    try {
                                        JSONObject jsonObject=new JSONObject(result);
                                        boolean b = jsonObject.getBoolean("ifsuccess");
                                        if (b){
                                            if ("customer".equals(getIntent().getStringExtra("customer"))&&!"updata".equals(getIntent().getStringExtra("TAG"))){
                                                Intent intent = new Intent(CustomerAppointmentAcitity.this,SimpleCustomerApoActivity.class);
                                                intent.putExtra("customerid",getIntent().getIntExtra("ID",0));
                                                startActivity(intent);
                                            }else if (!"updata".equals(getIntent().getStringExtra("TAG"))){
                                                Intent intent = new Intent(CustomerAppointmentAcitity.this, SimpleintmentActivity.class);
                                                intent.putExtra("id",getIntent().getIntExtra("dockid",0));
                                                Log.d("bb",getIntent().getIntExtra("dockid", 0)+"");
                                                startActivity(intent);
                                            }
                                            finish();
                                        }else {
                                            btn_commit.setVisibility(View.VISIBLE);
                                            if (jsonObject.getString("msgs")!=null){
                                                Toast.makeText(CustomerAppointmentAcitity.this, jsonObject.getString("msgs"), Toast.LENGTH_SHORT).show();
                                            }else {
                                                Toast.makeText(CustomerAppointmentAcitity.this, "添加预约失败", Toast.LENGTH_SHORT).show();
                                            }
                                        }
                                    } catch (JSONException e) {
                                        e.printStackTrace();
                                    }

                                }
                            });


                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }).start();
            }else {
                Toast.makeText(this, "预约时间不能早于当前时间", Toast.LENGTH_SHORT).show();
            }
        }else {
            Toast.makeText(this, "预约日期不能为空", Toast.LENGTH_SHORT).show();
        }
    }
    public static String getTime(Date date) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        return format.format(date);
    }
}
